<template>
    <div>
        <div>{{test}}</div>
        <van-button type="default" @click="pringTest">默认按钮-测试mixin</van-button>
        <van-button type="primary" @click="testToF">主要按钮-测试父组件传方法</van-button>
        <van-button type="info" @click="reduce">信息按钮-reduce使用</van-button>
        <van-button type="warning" @click="routeTo">警告按钮-路由props传参</van-button>
        <van-button type="danger">危险按钮</van-button>
        <BtnChild @btnChildEvent="btnChildEvent"/>
    </div>
</template>

<script>
import BtnChild from './btnChild.vue'
import { mixin} from './maxin'
export default {
    mixins: [mixin],
    props: ['receive'],
    components: {BtnChild},
    mounted() {
        // console.log(this.$refs.btnC)
        // this.$refs.btnC.demo()
        // this.$refs.btnC.$on('demo', this.getChildMsg)
    },
    methods: {
        testToF(){
            this.receive('我是来自btn的信息') // 太秀了
        },
        reduce(){
            let arr = ['a','b','c'];
            arr.reduce((pre,current)=>{
                console.log('pre',pre,'current',current)
                return pre+1
            },0)
        },
        getChildMsg(msg) {
            console.log('收到了子组件的消息', msg)
        },
        btnChildEvent(msg) {
            console.log('收到了子组件的消息', msg)
        },
        routeTo(){
            this.$router.push({name: 'Demo', query: {
                id: new Date().getTime()
            }})
        }
    },
}
</script>

<style>

</style>